-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(dsl): Support matchPhrasePrefix
query
#301
(dsl): Support matchPhrasePrefix
query
#301
Conversation
title: "Match Phrase Prefix Query" | ||
--- | ||
|
||
The `MatchPhrasePrefix` returns documents that contain the words of a provided text, in the same order as provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `MatchPhrasePrefix` returns documents that contain the words of a provided text, in the same order as provided. | |
The `MatchPhrasePrefix` query returns documents that contain the words of a provided text, in the same order as provided. |
val query: MatchPhrasePrefixQuery = matchPhrasePrefix(field = Document.stringField, value = "test") | ||
``` | ||
|
||
You can find more information about `MatchPhrasePrefix` query [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-match-query-phrase-prefix.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put empty line at the end of the file.
value = s"${firstDocument.stringField} te" | ||
) | ||
res <- Executor.execute(ElasticRequest.search(firstSearchIndex, query)).documentAs[TestDocument] | ||
} yield assert(res)(Assertion.contains(document)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can add && !contains(...)
for other document?
* @param field | ||
* the type-safe field for which query is specified for | ||
* @param value | ||
* the value to be matched, represented by an instance of type `String` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the value to be matched, represented by an instance of type `String` | |
* the text value to be matched |
* @param field | ||
* the field for which query is specified for | ||
* @param value | ||
* the value to be matched, represented by an instance of type `String` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the value to be matched, represented by an instance of type `String` | |
* the text value to be matched |
private[elasticsearch] final case class MatchPhrasePrefix[S](field: String, value: String) | ||
extends MatchPhrasePrefixQuery[S] { | ||
private[elasticsearch] def toJson(fieldPath: Option[String]): Json = | ||
Obj("match_phrase_prefix" -> Obj(fieldPath.foldRight(field)(_ + "." + _) -> value.toJson)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put empty line between.
assert(queryTs)( | ||
equalTo(MatchPhrasePrefix[TestDocument](field = "stringField", value = "test")) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be in one line?
Part of #91